using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Security;
using IWS.Lib.SingleSignOn.MembershipWebService;

namespace IWS.Lib.SingleSignOn
{
	internal class ProxyTranslator
	{
		public static System.Web.Security.MembershipUser GetMembershipUser(MembershipUserProxy user)
		{
			return new System.Web.Security.MembershipUser(user.ProviderName, user.UserName, user.ProviderUserKey, user.Email, user.PasswordQuestion, user.Comment, user.IsApproved, user.IsLockedOut, user.CreationDate, user.LastLoginDate, user.LastActivityDate, user.LastPasswordChangedDate, user.LastLockOutDate);
		}

		public static MembershipUserCollection GetUserCollection(MembershipUserProxy[] users)
		{
			MembershipUserCollection list = new MembershipUserCollection();
			foreach (MembershipUserProxy user in users)
				list.Add(ProxyTranslator.GetMembershipUser(user));

			return list;
		}

		public static MembershipUserProxy GetUserProxy(System.Web.Security.MembershipUser user)
		{
			MembershipUserProxy proxy = new MembershipUserProxy();
			proxy.Comment = user.Comment;
			proxy.CreationDate = user.CreationDate;
			proxy.Email = user.Email;
			proxy.IsApproved = user.IsApproved;
			proxy.IsLockedOut = user.IsLockedOut;
			proxy.IsOnline = user.IsOnline;
			proxy.LastActivityDate = user.LastActivityDate;
			proxy.LastLoginDate = user.LastLoginDate;
			proxy.LastActivityDate = user.LastActivityDate;
			proxy.LastPasswordChangedDate = user.LastPasswordChangedDate;
			proxy.PasswordQuestion = user.PasswordQuestion;
			proxy.ProviderName = user.ProviderName;
			proxy.ProviderUserKey = user.ProviderUserKey;
			proxy.UserName = user.UserName;
			proxy.LastLockOutDate = user.LastLockoutDate;
			return proxy;
		}
	}
}
